/*
 * @(#)Engine.java
 *
 *
 *
 * ver 1.0 Aug 16, 2007 ggranum
 */
package org.testfire.model;

import org.testfire.translator.TranslatorFactory;
import org.w3c.dom.Element;

public class Engine implements TestFireObject
{
    TestFireObject parent;

    String value;

    public Engine( Element el )
    {
        this.parse( el );
    }

    public String getValue()
    {
        return value;
    }

    public void setValue( String value )
    {
        this.value = value;
    }

    public StringBuilder toCode()
    {
        return toWatijCode();
    }

    private StringBuilder toWatijCode()
    {
        StringBuilder buf = new StringBuilder( );
        buf.append( "/** Engine: " ).append( value ).append( " */\n" );
        buf.append( String.format( "WatijBrowser engine = new %1$s();\n\n", value));
        return buf;
    }

    public void setParent( TestFireObject parent )
    {
        this.parent = parent;
    }

    public TestFireObject getParent()
    {
        return null;
    }

    public void parse( Element el )
    {
        this.value = el.getAttribute( "value" );
    }


    public Object translate( TestsetType testset )
    {
        return TranslatorFactory.translate(testset, this);
    }
}

// eof: Engine.java